from common.read_pathini import ReadIni
import configparser

# 获取账号配置文件路径
accountinfo_path = ReadIni().get_acountinfo_path()
# 调用外部的读取配置文件的方法
config = configparser.ConfigParser()
config.read(accountinfo_path, encoding='utf-8')


class ReadConfig():

    #读取URL
    def get_http(self, name):
        value = config.get('HTTP', name)
        return value

    # 读取配置文件EMAIL信息
    def get_email(self, name):
        value = config.get('EMAIL', name)
        return value

    # 读取配置文件DATABASE信息
    def get_mysql(self, name):
        value = config.get('DATABASE', name)
        return value

    # 读取配置文件LONIN_ACCOUNT信息
    def get_account(self, name):
        value = config.get('LONIN_ACCOUNT', name)
        return value


if __name__ == '__main__':  # 测试读取配置文件的方法是否可用
    print('HTTP中的baseurl1值为:', ReadConfig().get_http('baseurl1'))
    # print('EMAIL中的开关on_off值为:', ReadConfig().get_email('on_off'))
    print('DATABASE的port值为:', ReadConfig().get_mysql('port'))
    print('LONIN_ACCOUNT的county_username2值为:', ReadConfig().get_account('county_username2'))
    print('LONIN_ACCOUNT的city_password值为:', ReadConfig().get_account('city_password'))